<div class="content-section introduction">
    <div>
        <span class="feature-title">SplitButton</span>
        <span>SplitButton groups a set of commands in an overlay with a default command.</span>
    </div>
</div>

<div class="content-section implementation">
    <p-growl [value]="msgs"></p-growl>
    
    <p-splitButton label="Save" icon="fa-check" (onClick)="save()" [model]="items"></p-splitButton>
</div>

<div class="content-section documentation">
    <p-tabView effect="fade">
        <p-tabPanel header="Documentation">
                    <h3>Import</h3>
<pre>
<code class="language-typescript" pCode ngNonBindable>
import &#123;SplitButtonModule&#125; from 'primeng/primeng';
</code>
</pre>

            <h3>Getting Started</h3>
            <p>SplitButton has a default command button and a collection of menuitems to be displayed in an overlay.</p>
            
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-splitButton label="Save" icon="fa-check" (onClick)="save()" [model]="items"&gt;&lt;/p-splitButton&gt;
</code>
</pre>

            <h3>MenuModel API</h3>
            <p>SplitButton uses the common menumodel api to define its items, visit <a [routerLink]="['/menumodel']">MenuModel API</a> for details.</p>
    
            <h3>Properties</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>label</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Text of the button.</td>
                        </tr>
                        <tr>
                            <td>icon</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Name of the icon.</td>
                        </tr>
                        <tr>
                            <td>iconPos</td>
                            <td>string</td>
                            <td>left</td>
                            <td>Position of the icon, valid values are "left" and "right".</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                        <tr>
                            <td>menuStyle</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the overlay menu.</td>
                        </tr>
                        <tr>
                            <td>menuStyleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the overlay menu.</td>
                        </tr>
                        <tr>
                            <td>appendTo</td>
                            <td>any</td>
                            <td>null</td>
                            <td>Target element to attach the overlay, valid values are "body" or a local ng-template variable of another element.</td>
                        </tr>
                        <tr>
                            <td>disabled</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that the component should be disabled.</td>
                        </tr>
                        <tr>
                            <td>tabindex</td>
                            <td>number</td>
                            <td>null</td>
                            <td>Index of the element in tabbing order.</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            
            <h3>Events</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>onClick</td>
                            <td>event: browser event<br></td>
                            <td>Callback to invoke when default command button is clicked.</td>
                        </tr>
                        <tr>
                            <td>onDropdownClick</td>
                            <td>event: browser event<br></td>
                            <td>Callback to invoke when dropdown button is clicked.</td>
                        </tr>
                    </tbody>
                </table>
            </div>
          <h3>Severity</h3>
          <p>Different color options are available to define severity levels.</p>

          <ul>
            <li>.ui-button-secondary</li>
            <li>.ui-button-success</li>
            <li>.ui-button-info</li>
            <li>.ui-button-warning</li>
            <li>.ui-button-danger</li>
          </ul>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-splitButton label="Save" icon="fa-check" [model]="items" styleClass="ui-button-warning"&gt;&lt;/p-splitButton&gt;
</code>
</pre>
            <h3>Styling</h3>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>. SplitButton uses
            button and menu components internally, refer to their documentation for the detailed style list.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Element</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>ui-splitbutton</td>
                            <td>Container element.</td>
                        </tr>
                        <tr>
                            <td>ui-splitbutton-button</td>
                            <td>Dropdown button.</td>
                        </tr>
                        <tr>
                            <td>ui-menu</td>
                            <td>Overlay menu.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Dependencies</h3>
            <p>None.</p>
        </p-tabPanel>
        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/splitbutton" class="btn-viewsource" target="_blank">
                <i class="fa fa-github"></i>
                <span>View on GitHub</span>
            </a>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-growl [value]="msgs"&gt;&lt;/p-growl&gt;

&lt;p-splitButton label="Save" icon="fa-check" (onClick)="save()" [model]="items"&gt;&lt;/p-splitButton&gt;
</code>
</pre>
<pre>
<code class="language-typescript" pCode ngNonBindable>
export class SplitButtonDemo implements OnInit &#123;

    msgs: Message[] = [];
    
    items: MenuItem[];
    
    ngOnInit() &#123;
        this.items = [
            &#123;label: 'Update', icon: 'fa-refresh', command: () => &#123;
                this.update();
            &#125;&#125;,
            &#123;label: 'Delete', icon: 'fa-close', command: () => &#123;
                this.delete();
            &#125;&#125;,
            &#123;label: 'Angular.io', icon: 'fa-link', url: 'http://angular.io'&#125;,
            &#123;label: 'Theming', icon: 'fa-paint-brush', routerLink: ['/theming']&#125;
        ];
    &#125;

    save() &#123;
        this.msgs = [];
        this.msgs.push(&#123;severity:'info', summary:'Success', detail:'Data Saved'&#125;);
    &#125;
    
    update() &#123;
        this.msgs = [];
        this.msgs.push(&#123;severity:'info', summary:'Success', detail:'Data Updated'&#125;);
    &#125;
    
    delete() &#123;
        this.msgs = [];
        this.msgs.push(&#123;severity:'info', summary:'Success', detail:'Data Deleted'&#125;);
    &#125;
&#125;
</code>
</pre>
        </ p-tabPanel>
     </p-tabView >
</div>
